Thank you for the response Peter. Pygame image to string code below
def displayscreen():
  ## image_filename = str(va.page) + ".jpeg" Â# va.page is the current page no
  filename = "zxs" + str(va.page) + ".ada"
  ## images are saved in runs.py and to use it storeno = 2
  image2blit = getfrompy.main(filename, storeno = 2)
  if image2blit == None:
    ## no image saved in file so draw the screen with make_screen_text
    make_screen_text()
    ## now grab the screen
    screen = SCREEN.subsurface(0, 0, SCREENW, SCREENH)
    ## convert to string
    screenstr = pygame.image.tostring(screen, "RGBA", Falsey)
    ## nowencode and write to dict in runs.py
    strA = XOR(screenstr, coder)
    str1 = base64.b64encode(strA)
    scrnstore [filename] = str1
    image2blit = pygame.image.frombuffer(screenstr, ( SCREENW, SCREENH ), 'RGBA')
  va.getscr = True
  return image2blit
this code took too long to convert back and fourth. around 6 seconds.
      screen = SCREEN.subsurface(0, 0, SCREENW, SCREENH)
      image2blit = pygame.Surface.convert_alpha(screen)
      memsave = StringIO()
      pygame.image.save(image2blit, memsave)
      memsave.seek(0)
      pygame.image.load(memsave, iname) Â<- code crashes here
      strA = XOR(iname, coder)
      str1 = base64.b64encode(strA)
      scrnstore [filename] = str1
the above code crashes at the point marked with the message pygame.error: unsupported image format. What I want to do is to grab the screen surface, convert it to a string format and save to a dictionary.
The dictionary will be pickled and saved to a file.
I want all my images in this file and NOT AS IMAGE FILES ON DISK.
Please help to resolve this.