fixed bug reading header with different encoding