Tweaked mask conversion script