Beginning of Python 3/Django 1.6 compatibility

These fixes are enough to get the management commands running on Python 3, and they are backwards compatible with Python 2.

Note that this doesn't even sort of make haystack py3k-compatible. There's still a lot of callable(), unicode(), basestring and long references scattered but I didn't want to pollute the first patch set.