issue175 inputvalidation

Updated pull-request to implement validation in the input as #175 
You seem to be assuming the file was opened in binary mode. Did you only try this in Python 2? Python 3 is a lot stricter.