credo che dovresti usare i buffer e dare un utf8_encode prima di andare in output