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.

This needs to be base64 encoded like the old headerstate was since the settings table uses TEXT fields not BLOBs (so it needs to be encodable as utf-8).