Fix py3k portability issues