Dolphins beat 49ers