Improvements to binary file detection

  * Comments to explain magic numbers 80, 4 and 50
  * rescue exceptions
  * open file in binary mode