Spectral methods for the solution of optimal control problems