Fixed handling of characters. Python 2 and 3 do it in a different way.