masks, opencl: fix memory leak

make use of opencl memory more economical. also fixes a (not understood) bug
with AMD devices