I don't understand your code:
I looks like you are expecting gimp-file-load-layer to "fill" MaskLayer. In any case, gimp-file-load-layer creates a new layer and returns it, so if you don't set a variable with whatever is returned from gimp-file-load-layer you will have trouble accessing the loaded layer.
Also, in Gimp 2.10, instead of using a mask, it could be simpler to use a layer in Erase blend mode.
Code:
(gimp-layer-new Image ImgW ImgH RGB-IMAGE MaskLayer 0 LAYER-MODE-NORMAL)
(gimp-file-load-layer RUN-NONINTERACTIVE Image Mask)
(gimp-image-set-active-layer Image MaskLayer)
I looks like you are expecting gimp-file-load-layer to "fill" MaskLayer. In any case, gimp-file-load-layer creates a new layer and returns it, so if you don't set a variable with whatever is returned from gimp-file-load-layer you will have trouble accessing the loaded layer.
Also, in Gimp 2.10, instead of using a mask, it could be simpler to use a layer in Erase blend mode.