Added image conversion and pygame.QUIT handling