Abalkin py3k fixes

Don't merge yet as I'm running the tests.