Magnetoelastic coupling in RuSr2GdCu2O8