Add option to compress serialized data with zlib if supported

Wraps compressed data with new version number (3).
Includes settings for compression level and minimum size to use compression.
Does not use compressed version if not smaller than original.