Mask extraction and transformation

Mask extraction and transformation are working.