code: public static void writeToPath(BitMatrix matrix, String format, Path file, MatrixToImageConfig config)
        throws IOException {
      BufferedImage image = toBufferedImage(matrix, config);
      if (!ImageIO.write(image, format, file.toFile())) {
        throw new IOException("Could not write an image of format " + format + " to " + file);
      }
    }
docs: As {@link #writeToPath(BitMatrix, String, Path)}, but allows customization of the output.
  
  @param matrix {@link BitMatrix} to write
  @param format image format
  @param file file {@link Path} to write image to
  @param config output configuration
  @throws IOException if writes to the file fail