How exactly do you calculate the hidden layer gradients in the backpropagation algorithm?
You've transposed the sizes of both $w^L$ and $\delta^{x,L}$.  $w^L$ should be 2x4 and $\delta^{x,L}$ should be 2x1.  $(w^L)^T$ is a 4x2 matrix that will be multipled by a 2x1 matrix yielding a 4x1 matrix suitable for the next step of backpropagation.
In general for neural nets the activation units are represented as column vectors and the weights are matrices of dimension |L+1| x |L|, where L is the current layer and L+1 is the next layer (in the forward direction).