Apply 2to3 script
Fix str encode to support Python 3