Practice, practice, practice. It doesn't recreate the stress of an interview, but it will help you form habits you can rely on when you are stressed. There are any number of book on programming interviews. Get together with a programmer friend and run through mock interviews. You may also get lucky in the real interviews and be asked a problem similar to one you've already done.