Python3 compat

This allows the tests to pass on python3, but I'm sure there is more work to be done to ensure that it fully works.