Asterisk Transcoding between g711 and t38 and Fax detection

I am hoping somebody has a soluion for this.
i have to providers 1 supports g711 fax and the other supports t.38 fax is there any way to transcode between the to.

my other question is with codec preference
if the call comes in as a G711 fax does asterisk 1.6 know that is a fax and not transcode it to the prefered codec
Allow g729,alaw

P.s G711 works well when there is only 1 codec pref on 1.2 and 1.4 but i want to prioritize G729 on the link for BW saving
Currently bandwidth is not an issue be will be to some sites.

Cheers Darren