private byte[] get_img_stream(File dot, String type)
   {
      File img;
      byte[] img_stream = null;

      try {
         img = File.createTempFile("graph_", "."+type, new File(GraphViz.TEMP_DIR));
         Runtime rt = Runtime.getRuntime();
         
         // patch by Mike Chenault
         String[] args = {DOT, "-T"+type, dot.getAbsolutePath(), "-o", img.getAbsolutePath()};
         Process p = rt.exec(args);
         
         p.waitFor();

         FileInputStream in = new FileInputStream(img.getAbsolutePath());
         img_stream = new byte[in.available()];
         in.read(img_stream);
         // Close it if we need to
         if( in != null ) in.close();

         if (img.delete() == false) 
            System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!");
      }
      catch (java.io.IOException ioe) {
         System.err.println("Error:    in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR+".\n");
         System.err.println("You may need to install the programm GraphViz from http://www.graphviz.org/ \n" +
         		"It's an free graph visualiation software. After installing just make sure that the program 'dot' is " +
         		"in the folder: " + GraphViz.DOT);
       //custom title, error icon
         JOptionPane.showMessageDialog(new JFrame(),(
             "There is a problem to draw the loaded perceptron! You may need to install \n" +
             "the programm GraphViz from http://www.graphviz.org/\n" +
         		"It's an free graph visualiation software. After installing just make sure \n" +
         		"that the filepath for the program 'dot' is: "+ GraphViz.DOT),  "Program not found",
             JOptionPane.ERROR_MESSAGE);
      }
      catch (java.lang.InterruptedException ie) {
         System.err.println("Error: the execution of the external program was interrupted");
      }

      return img_stream;
   }