More bug fixes. Had to force encoding to ISO-8859-1 to make binary output from PHP work properly.