Quote from the movie "The mask of Zorro" : He probably wears the mask to hide his bald head and unsightly features.
While in the movie the mask was not to hide the bald head and unsightly features, this is more or less the case when working with mask for QR Codes.
Masking in QR Codes is used to eliminate certain patterns, or unsightly features, in the graphic that could cause scanning problems.
While making a QR Code, the content of the QR Code could generate patterns in the graphics that a scanner could misread as a corner marker. The mask function in a QR Code is to distribute the light and dark elements in such a way that the overall light/dark ratio is close to 50 % and unwanted patterns are mostly eliminated. A generated raw QR Code will 'try on' all eight these mask, and select the specific mask that fits the best.
During designing Custom QR Codes, the routine of selecting the best fit mask could be applied to a QR Code if a graphic is inserted. A graphic pasted in the QR Code will generate errors in the QR Code build-up. By applying the other masks, the mask that generates the least amount of errors can be selected to keep the code useable.
An even better alternative is the method offered by Kangaderoo, recalculate the QR Code content after a picture is inserted, thereby eliminating all the errors inserted by the graphic. Its better to fix the problem then to mask the problem.