Avoid record size exceeded errors

The API returns a record size exceeded error if the size of either the input or output exceeds 32,768 (32K) bytes.