I think there are two good ways to improve your mental stamina.
The first is to play long time control games regularly. I try to play a 90 minute with 5 second delay game each day on-line. This will keep my mind active and prepare me for tournaments when I will have to play 2 or 3 long games in 1 day.
The second is to regularly go through chess puzzles. The resource I like to use for this is the "Chess Tactics Server", http://chess.emrald.net/ , each day I try to log onto this site and do 50 puzzles. This has really helped me to prepare myself for the intense mental focus needed to play the longer time control games.
I hope that these suggestions will help you to improve your mental capabilities.
In my attempt to get better, I played my first 20/40 move/minutes game on the computer, writing down moves and staring at my board instead of the screen. I didn't really understand that this meant the game could go on for around 2 hours, so when it did I was mentally exhausted. All my OTB chess has been blitz/short standard (usually no more than a 30 minute game), so this was way out of my league. I ended up wasting away an even endgame by giving my opponent an easy fork. I guess I should add that I got a few vaccinations the day before, and am experiencing the side effects, so maybe that is the culprit.
But in general, how does one improve their mental stamina/endurance to maintain your best play throughout a long game?