Python 3 compatibility

I had never seen this before, but after looking into it, it seems reasonable.