I'm not sure I understand you entirely, but it is really not needed to have a seperate file to get transparency. Tga files for example have an extra alpha layer (provided they're saved correctly (32 bit)) Using Paint Shop Pro or PhotoShop its fairly easy to create an alpha layer.

The whole suggestion of looping through an image, reading each pixel and change it to a certain color is not only a long and difficult process, it is also completely unnecessary.

Have a look at this sample. It has everything you need.