Let p be a prime and let q be a power of p. In this paper, by using generalized Reed-Solomon (GRS for short) codes and extended GRS codes, we construct two new classes of quantum maximum-distance-separable (MDS) codes with parametersfor any 1 ≤ t ≤ q − 1, 2 ≤ d ≤ t + 2 with (p, t, d) = (2, q − 1, q). Our quantum MDS codes have flexible parameters, and have minimum distances larger than q 2 + 1 when t > q 2 . Furthermore, it turns out that our constructions generalize and improve some previous results.