Update code to work with Python 3.
Revert formatting that was accidently changed in previous revision.