Update canvasmask.js

- removed unused vars
- used Array.forEach instead of while loop, thus moving the variables into iterator scope
- reduced overall amount of vars