Makes this all work for python3

Fixes up a few small problems elsewhere too. Thanks for the great tutorial!