Cleanup and pseudocode for get image sample