Python 3.3 compatibility

Basic changes, works for me, YMMV.