Python 3 compatibility patch provided.

It's a pretty dirty hack, but it add Python 3 compatibility in a really easy way. I'd appreciate this or similar fix to be included in the codebase.