Joint inversion of gravity and magnetic data for two-layer models