Moving towards Python 3.x compatibility

This fixes all the "low hanging fruit" (renaming functions etc.). Close
to 200 test failures remain.