add check if directory where write image exists, otherwise it create it