Fixed typos in MaskImageOut

Fixed typos and replaced length(size(m)) with ndims(m).