you can't have an image, that is part 1 channel, and 4 channel otherwise.
the blur example worked fine, because it did not change the number of channels.
you'll have to convert your gray (sub)img to rgba again, before copying
Mat temp = new Mat();
Imgproc.cvtColor(mask, temp, Imgproc.COLOR_BGRA2GRAY,0);
Mat temp_rgba = new Mat();
Imgproc.cvtColor(temp, temp_rgba, Imgproc.COLOR_GRAY2BGRA,0);
temp_rgba.copyTo(mask);