Support international characters in formatter

Use StringWriter instead of ByteArrayOutputStream so Unicode characters won't become ????s.