Here's what I did - though it may be too late for some:
I never, ever just let my son win while he was growing up.
This was not always easy. For a while, for example, I could always count on him to side with his mother when we played A Game of Thrones. It was OK, she was going to win anyhow.
Sometimes, he would score a win - usually in luck based games - and he would be congratulated. But I always told him when he played well, thanked him for the game, and helped him after the game was over by discussing what went wrong and what he might have done better. And I pointed out when he made good moves or decisions, during the game, too.
As a result, he got a lot of practice losing - and what I hoped was a good model for a gracious winner, too. He also got an absolute certain knowledge that when he won, he deserved it. Nobody can take a win away from him by saying, "Well, I just let you win that one," because it simply never happens. So now, when he regularly kicks my butt, he knows he did it legitimately, and he usually models excellent gracious winner behavior for me when he does.