Added a buffer array to store image state.