Implemented caching of masks as files