Add CopyWithMask method