Fix string handling to work on Python 3 as well.