Returns compressed bytes.
Implementations should enforce limits while encoding. The writer also validates the returned byte count before using it.