Python 3

This updates the file to work with Python 3 without breaking Python 2 support.