Pyrolysis of waste feedstocks in CO2 for effective energy recovery and waste treatment