Speed up draw_seg by storing mask