Python 3 compatibility changes

I'm not saying that it's *all* that needs to be changed; but I went through the functionality and it seems to run now also on python 3 (tested on Python 3.4, django 1.6.2).