Replace ByteArrayOutputStream - help image encoding performance