Bin and unbin masks and flat images.
Related to #9