Bug fix: Ensure output directory exists.