Python 3 Compatibility

Changes are from running 2to3.py.