'Dear John' beats out 'Avatar' at box office