Fix output paths to support nested dirs