Run under Python 3

This will make the code I wrote in http://lists.wikimedia.org/pipermail/wikitech-l/2014-May/076373.html actually work in modern versions of Python.

It probably won't fix all issues, but it does seem to run some basic stuff now.