Wave energy converters (WECs) require active control to maximise energy capture over a wide range of sea conditions, which is generally achieved by making the device resonate. The exaggerated device motion arising at resonance, however, may result in nonlinear effects that are ignored by the linear models that are typically employed. In particular, nonlinear viscous forces are significant for particular device types, such as hinged flaps, which we take as a case study in this paper. The paper develops a general nonlinear WEC control methodology based on pseudospectral methods. The continuous time energy maximisation problem is fully discretised (both state and control), and the optimal solution is obtained by solving the resulting finite dimensional optimisation problem. By way of example, the nonlinear viscous damping for a hinged flap WEC is incorporated into the control model which also considers non-ideal power take-off efficiency. It is shown that the ratio of energy captured to energy dissipated is significantly increased with the nonlinear controller, compared to the linear case.