Python 3 support

I made a few minor alterations and it now seems to run on Python 3.3.