fix ByteArrayOutputStream cannot be cast to byte[]