bunch of py3k fixes