add output dir for latex compilation
cleanup and use masterfile