Add Python 3 support

Requires Pillow (instead of PIL) and latest PyGame from Mercurial, but it works now. Also moved all config file logic to one place to avoid duplicating ConfigParser hacks all over the place. This is a first draft version of the patch, I'll make it look prettier later.