Exe template refactor

Re-opened after proper branching, and fixing a couple of issue pointed out by limhof-r7 regarding the file open techniques.

Please see the previous PR: https://github.com/rapid7/metasploit-framework/pull/2262