encoding fix for type() function in py2