CAS-14201: Fix bug with mask=[]
If mask is passed in as an empty list, in the case of niter=0 the return
dictionary construction fell over. os.path.exists() wants an empty
string, but if an empty list was passed in it threw a KeyError.
This is now fixed by putting in the appropriate guard rails before it
gets to os.path.exists. The length of the input mask is tested, so
regardless of empty string or list it will catch it there.