Python3 compatibility 

Allright, so here's my shot at making it compatible with py3. I have described the changes in the commit message. Since this is my first contribution on github, I hope I am doing this the right way :).