First pass at Python 3 compat

So far this has only been tested on Linux