On-the-fly Generation of Spatial Transfer Functions for Efficient Monte Carlo-TH Coupled Calculations