changed from cStringIO to StringIO, and wrapped the string and a utf8 encoder/decoder