not using cStringIO.StringIO anymore due to encoding trouble