code: def write_image(self, filename="image.png", magnification=1,
                      image_format="png"):
          
          render_large = vtk.vtkRenderLargeImage()
          render_large.SetInput(self.ren)
          if image_format == "jpeg":
              writer = vtk.vtkJPEGWriter()
              writer.SetQuality(80)
          else:
              writer = vtk.vtkPNGWriter()
  
          render_large.SetMagnification(magnification)
          writer.SetFileName(filename)
  
          writer.SetInputConnection(render_large.GetOutputPort())
          self.ren_win.Render()
          writer.Write()
          del render_large
docs: Save render window to an image.
  
          Arguments:
              filename:
                  filename to save to. Defaults to image.png.
              magnification:
                  magnification. Use it to render high res images.
              image_format:
                  choose between jpeg, png.  Png is the default.