Try to pass only the image to the transformation and check if it works.
If you would need to transform the image and the mask together (using the same “random” transformations), I would recommend to use the functional API as described here 9.