wrapping output stream in a writer so we get the correct encoding - #812