A Lyapunov-based Approach to Safe Reinforcement Learning