You can check the source of UPX of course for this.
I know another website which uses this technique and publiced some information about the headers, I thought it was
http://www.exesecure.com, they do the same actually. Maybe you can recompile the program for convenience.