fixed issue with stringio always being closed; fixed encoding error