Fixes for py3k.

Current HEAD is broken for py3k. Here are some fixes.