Port to Python 3.

I haven't tested this, but it should do the trick.