Process for treating and generating energy from biomasses