Too long answer (longer than I wanted it to be), because @dhx covered the more important stuff so well. This is just another tool for the kit.
I suggest you start teaching the child the subject informal logic. It's usually a high school class, e.g. in prepping for debates, but since one goal is to improve reasoning skills, there's absolutely no reason you can't start right now with real world examples.*
Bifurcation (or black/white, all/nothing thinking) is a very common fallacy, especially in children; basically it supposes there to be only two alternatives when in fact there are more. An example is that something is either good or bad, when in fact, there is a wide range of possibilities.
Start with easier things, say, "I stink at tic tac toe/noughts and crosses/(something)." After addressing the feelings your child is experiencing ("That must feel bad! Does it? What are you feeling?" (it could be disappointment, frustration, or a number of other things. An emotional vocabulary will help a lot with this.) This validates the child in that you care about how he's feeling and that you can understand why he feels that way. Then, you address the possibilities. How many (e.g.) games of tic tac toe has he played? Has he ever won? Does losing more than once automatically make him a bad player? Is it possible to be average? Is it possible to have bad days and good days? Explore the possibilities. When the child is calm sometime, explain that all/nothing thinking is an example of an idea called "bifuraction". You can illustrate this by, say, drawing a line on a piece of paper which branches into a fork. (the word bifurcation basically means a fork with two tines, like the early forks people used to eat food with.) If you then ask him to draw a fork, hopefully he will draw one with three or four tines. See? A line can divide into many lines, not just two.
Emotions are harder, but can be dealt in a similar manner. After validating the child, you can point out another (extremely common) fallacy: the ad hominem (attacking the person, not the thing).
An example: John fell. John is an idiot.
There can be a hundred reasons that John fell. He might have tripped on something on the ground. He might have felt feint. He might have a balance problem, or muscle weakness in his leg. None of that means anything about his character.
Another example: John wrote something poorly. He might be very young and without the practice it takes to write neatly. He might be in a rush. He might be thinking about other things. His fine motor skills might need more work. None of these things means anything about his character.
Perhaps the next time your son says, "I'm a terrrible kid," You can validate his feelings (That must feel so bad! I'm so sorry you feel bad.) then explore them: Are you feeling anything else? Do you feel frustrated? Do you feel "less-than"? Do you feel like you're not good enough? This is where a good emotional vocabulary is extremely helpful.
Then bring up the fact that a single thing - a mistake, a defeat, a problem with handwriting, whatever, doesn't mean anything about his character. That's an ad hominem: instead of focusing on the problem, he's focusing on the person.
Remind him every time that who he is doesn't depend on any one thing, but on many, many things. You don't need to praise him excessively, which might be seen as an invalidation of his feelings, but you can build him up.
It's ok to feel _______, but feeling _______ doesn't make you a terrible person. If that were true, we would all be terrible people, because everybody feels _______ sometimes. I feel _______ when _______. When I feel _______, I try to think about the times I (did something that made you feel the opposite, etc.)
Sorry this is so long. It's about critical thinking, emotional vocabularies, and resilience. Those are difficult to cover in a brief answer.
*I started teaching informal logic to my kids before kindergarten. Back then, there were commercials/ads on television. I wanted them to be able to identify the fallacies used in television advertisements so they could counter their influence. Toy commercials (and for adults, beer [any alcohol, really] commercials) are a great example. Basically, at that point, I was starting to teach critical thinking and its application to media.