Make codebase compatible with Python 3.

Making this PR to allow Travis CI to run;  there are still known issues with the annotations.