Intermediate valence and semiconductor-metal transition of TmS1−xSex and TmSe1−yTey