Mask at header creation time

This is much more efficent, as it can be done using the frame
buffer rather than copying a users buffer