Refactored texture export code.