Start moving towards Python 3.x compatibility.

Inspired by the pull request from energynumbers.