Fix codec handling by saulecabrera · Pull Request #464 · Shopify/function-runner

@saulecabrera

This patch fixes how the encoding codec is handled across the entire
codebase.

Prior to this commit, support for codecs other than JSON was
incomplete, mainly since the code assumed that all function output must be valid .

Proper handling of codecs involves:

* Validating JSON as the canonical input to function runner.
* Encoding from JSON to a given codec if needed
* Encoding to JSON from the function's output if needed and ensuring to
keep save any encoding errors when needed.

In order to achieve proper codec handling, I opted to encapsulate
the details related to input and output bytes in a container
(`BytesContainer`), which can either hold input or output bytes, and
simiarly perform all the byte-level operations needed for reporting,
such as calculating the length, presenting a human-readable
representation, etc.

This commit also adds the proper tests for each codec.