From http://www.codeproject.com/Articles/17825/Reading-and-Writing-Binary-Files-Using-JScript