we need to modify the share files for Sharepoint located under
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\
MSDN Resources: http://support.microsoft.com/kb/944105
(How to customize application pages in the Layouts folder in SharePoint Server 2007 and in Windows SharePoint Services 3.0)
Or to use this custom way of implementation refer this: http://weblogs.asp.net/soever/archive/2006/11/14/SharePoint-2007_3A00_-using-the-masterpage-from-your-site-in-custom-_5F00_layouts-pages.aspx
Although modification on the build in pages it is not really supported by SharePoint, there is something that we could do to overcome this.
Another method by Stephen Kaye http://stephenkaye.blogspot.com/2008/03/how-to-customise-applicationmaster-file.html
Other good references: http://www.graphicalwonder.com/?p=479