Adding error mask code (quick error detection based on blur / dilate / erode)