Python 3 compatibility

These look like the only changes necessary for python 3 compatibility.

Tested with python 3.4.1 with my own small project.

Are there some more thorough tests I could run?
This doesn't display properly unless it starts with '\n'. The result is that there's a blank line that prints when the script starts.