Python 3 support

Here's a Python 3 port for your consideration. As of now it passes the tests, but I haven't tried to run it in any real world situations.