Go into Render Globals and tick the box that says "Alpha Channel (Mask)" in the image output settings.