Generalized master function approach to one-dimensional quasiexactly solvable models