Discretizing stochastic dynamical systems using Lyapunov equations