France and Spain are battling vast wildfires that have forced more than 325,000 people to flee, as a new heatwave looms.