Revert "Revert "Update to TWAIN functions""

This reverts commit 65f091061020472e8737a72c6bff7b91486f9af9.