Open tempfile in write mode

Fixes #148
Run test suite on Travis using ruby 2.1.1