Avoid copy of output using Seek
Summary: Instead of outputting to an in-memory buffer, then copying the header and output buffer into some value implementing `Write`, accept a value implementing `Read + Write + Seek`. Output into the writer directly by writing a dummy header of 20 zero bytes at the start. If, after writing the output, we find we only need to write a small (20 byte) header, we can just seek back to the start and overwrite it. If we guess incorrectly and need to write a big (32 byte) header, read the output back into a buffer, write it back out at offset 32, then write the large header at offset 0. [extern.c does something similar here](https://github.com/ocaml/ocaml/blob/4.14/runtime/extern.c#L955).
Reviewed By: shayne-fletcher
Differential Revision:
D39451054
fbshipit-source-id:
00564d69cb6e8bee42229deaf29f03c460306020