Fix mishandling of incomplete, inverted masks.

This fixes #4926. Sometimes image masks have less data than the height*width requires. createMask() was handling this correctly on normal masks, but when the mask was inverted it did the wrong thing.
To fix the lint error, please move `var i` to the top of the function (placed among the other variables) and remove it from [R284](https://github.com/mozilla/pdf.js/pull/4933/files#diff-7105ab0e122d5ff915e2f8e96347d136R284) too.