Baytex Energy to buy Ranger Oil in $3.4bn deal