\begin{wrapfigure}{l}{5cm}

\centering
\vspace{-1.5em}
\begin{tikzpicture} 

\foreach \x in {0,...,8}{
\draw (0, \x/2) -- ( 4, \x/2 );
\draw (\x/2, 0) -- ( \x/2, 4 );
}

\foreach \x in {0,...,7}{
\draw[thick, color=red] ( 0.25, \x/2 +0.25) -- ( 3.5 - \x/2+0.25, 3.75 );
}

\foreach \x in {1,...,7}{
\draw[thick, color=red] ( 3.75, 3.5-\x/2 +0.25) -- ( \x/2+0.25, 0.25 );
}

\foreach \x in {0,...,2}{
\draw[thick, color=red] ( 0.25, 0.75 + \x ) -- ( 0.25, 1.25 + \x );
\draw[thick, color=red] ( 3.75, 0.75 + \x ) -- ( 3.75, 1.25 + \x );
}

\foreach \x in {0,...,2}{
\draw[thick, color=red] ( 0.25 + \x, 0.25 ) -- ( 0.75 + \x, 0.25 );
}

\foreach \x in {1,...,3}{
\draw[thick, color=red] ( 0.25 + \x, 3.75 ) -- ( 0.75 + \x, 3.75 );
}

\draw[thick, color=red, >-] ( 0.25 , 3.75 ) -- ( 0.75, 3.75 );
\draw[thick, color=red, ->] ( 3.25, 0.25 ) -- ( 3.75, 0.25 );

\end{tikzpicture}
\caption{Entropy Coding}
\label{fig:jpegordering}
\end{wrapfigure}
