Fixed issue where special characters were not encoded properly and were causing errors with generated php document.