1) Bugfix and extensive testing of patch iterator. 2) Added an assembleimage function.