Writing image with the size of viewport instead of frame