Port imagerecat.py from compat

Change-Id: I9e5f5a1fb1823ec85378d3bf9d7c67592139face