Python3

Just a few edits to make it compatible with Python3. It still works with Python2.7 as well. I did not test on 2.6 or lower.