A Hamiltonian Formulation and a Direct Numerical Scheme for Fractional Optimal Control Problems