Remove all direct uses of str(); use text_type()

/cc @viobo @Kjwon15