Some fixes for compatibility with python3

I can't assure real compatibility with python3 because the tests doesn't work, but at least fail in the same way.