Retry installation commands on Travis CI

As recommended in http://blog.travis-ci.com/2013-05-20-network-timeouts-build-retries/
Merge pull request #2457 from danielgtaylor/travis-retry

Retry installation commands on Travis CI. Fixes #2457.