Let's say you created a master page and put it to the Master Pages and Page Layouts Gallery. After a while, you wanted to delete the master page but you got the "This item cannot be deleted because it is still referenced by other pages". error. Do not be frightened. This is a bug and there is no solution for this situation. Microsoft offers a workaround for this situation which you can find at this link:
http://support.microsoft.com/kb/926812