Implement user-data in header functionality

Not exposed to Perl yet and probably still broken.

Also introduces a second buffer struct in the encoder that can be used
for swapping in-and-out while not risking memory leaks during
exceptions. That second tmp buffer could also be used for the Snappy
compression.