Re-implemented binary storage format (content and flags) from Couchbase 1.x SDK.

Change-Id: I1034443cdded728ec9a44933ad0241381dd2a027