Updated patch from #34 for goToPage issue with loop: false

This patch fixes several issues relating to `goToPage()` where `loop: false`. 

If you disable looping and use a `goToPage()` the `masterPage` 0 will stay as invisible but potentially the next page will be visible (which shouldn't). Similarly, `goToPage(2)` would result in the destination page being hidden.

This pull request supersedes #34 and consists of the solution to provided by @linlex, which has been confirmed to work.