Python 3 compatibility

This looks like the only change 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?