Add support to create output directory if it doesn't exist.