The mask image isn't identified automatically by the prodtype/proctype keywords (these are pulled from the headers), however you can do a search on the 'accessURL' field for the substring 'maskbits.fits.fz' to find the image. Note this trick is peculiar to the Legacy Survey images.