Foreground Subtraction of Cosmic Microwave Background Maps Using WI-FIT (Wavelet-Based High-Resolution Fitting of Internal Templates)