Support serializing to NSData (to allow background thread serialization)