public function setOutputPath($path)
    {
        $outpath = $path;
        if (!file_exists($outpath)) {
            if (!mkdir($outpath, 0755, true)) {
                throw new BadOutputPathException(
          sprintf(
            'Output path %s does not exist and could not be created!',
            $outpath
          ),
          $outpath
        );
            }
        } else {
            if (!is_dir(realpath($outpath))) {
                throw new BadOutputPathException(
          sprintf(
            'The argument to `output` is expected to the a directory, but got %s!',
            $outpath
          ),
          $outpath
        );
            }
        }
        $this->outputPath = $outpath;
    }