Fix bug in viewport offset with different aspect ratio

This fixes the bug reported at https://trello.com/c/mFJYC9Pl/59-offset-bug-when-aspect-ratio-of-panel-is-changed.

To test, try resizing image panels to change aspect ratio (tall or wide). Pan, zoom, rotate etc and check that the PDF generated is same as figure in web.