Added the missing support for masking when writing frames.