Solving Hamilton-Jacobi-Bellman equations by a modified method of characteristics