Python 2.7 io.StringIO is text-only, use backwardcompat