Energy transfer between modes in a nonlinear beam equation