Fixed vertical traversal issue

It wasn't traversing correctly for all pixel storage formats.