Add custom library header save/restore code.

Should migrate current 1.12 installations from the old QT binary blob
to the new protobuf format.  This won't help us for users upgrading
from 1.11, but all future upgrades should be much smoother.
includes a small roundtrip test.

I think we should remove this and let the old headerstates stick around for backwards compatibility. Loading up 1.12 and then switching back to 1.11 will work that way without losing or corrupting your headerstates if 1.12 doesn't touch the headerstate at all.