add encoding magic for py2.7