Method for generating a panoramic image