fixed writeheader call to support 2.6