mask calculations, better file name handling
new dir for output