Structural and magnetic phase transitions in the ternary iron arsenides SrFe2As2 and EuFe2As2