Expose serialize method.