Added functionality to automatically create an output directory if it
does not exist