LPS-43301 Optimize OutputStreamWriter and WriterOutputStream