Support Python 3

I ran 2to3 on the code, and this works for me using Python 3.4.