Add option to compress serialized data with zlib if supported

Wraps compressed data with new version number (3), existing code is not modified.
Includes settings for compression level and minimum size to use compression.