Add several negative tests for encoding.

This commit adds a new fixed writer type to the tests which is used to
force errors during the encode by limiting how much is allowed to be
written to less than is required.