Add mask option to cut1d, move function implementation to utils.asy.