What does help me too is to just start on something and not procrastinate. If you survived the first 2 seconds of starting, you can go on for hours.
And the code isn't actually bad. The real problem is that it also makes you into a perfectionist who starts to write his own jpeg library if he finds anything about libjpg that he does't like.
Worse, I remember that I disliked the task through its entirety and I'm very acutely aware of that and start associating starting it with a bad experience.