Hoist out main LZW code function.
Hopefully by pulling it out from a closure / inner function, there will be
only a single copy of the code shared across all instances, and the compiler
can spend less time compiling the functions and optimize it better.
Additionally it brings most of the GIF format related writing code together,
which is a nicer read.
Manually inline emit_code / emit_bytes_to_buffer in core encoding loop.
This isn't the most attractive deal, but it gets something like 15%.