Port code to Python 3

This PR ports the code to Python 3 without any attempt to retain backwards compatibility with Python 2. You may want to merge this into a separate branch and document that it exists in the README. I'm not sure what else to do with it. I ported it to Python 3 for my own usage and felt that others may find this useful.