Mask out ocean

Is there a way to mask the ocean in global data? I mean, not replacing the values in the ocean with null or zeros, but cutting them to reduce the size of the output files. The output files I need are land only.

Thanks in advance,