Minor fixes for Python 3 support

Thank you for sharing this. I've made some minor fixes in order to support Python 3 and would like to share them with you should you want to incorporate them.