Add the ability to specify mode in Rex output file

* Because sometimes you might want to append
* Preserves original hardcoded 'wb' as default
* http://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html
Land #4192, enable specifying mode for Rex output file