SublimeText 3/Python 3 compatibility

These changes are *mostly* for compatibility with Python 3. The 2to3 script did most of the work.