Tar formation in pyrolysis and gasification