Python 3 compatible string handling