WIP: write debug image

Change-Id: I4cacdd4ed46193f335257af4d487567a68b9fb5f