Python 3 fixes

A few small changes for Python 3 compatibility.