Plumbing Random Paths
CJam, 274

q~:K;:B;:A;{0aA*aB*:M5*5f*:I;K{[Bmr:QAmr:P]5f*:R;3Ym*{R.+:)2{1$0=I=2$W=@tI@0=@t:I;}:F~}/R2f+1FK({MQ=P=:EY4mr:D#&amp;1{{MQMQ=PE2D#+tt:M;}:G~7,1&gt;[W0_1_0_W]2/D=:Off*{[QP]5f*2f+.+_:H1F_OW%.+2FOW%.m2F}/H2FO~P+:P;Q+:Q;MQ=P=:E_5YD2%-*=!JK2-=+*1{D2+4%:D;G}?}?}fJ]}0?}g'P2NA5*SI,N2NI:+N*


Try it online

Uses PBC, outputs in PGM format. You can remove the :+ near the end to get a nicer visual output in the browser.

It's very slow for larger input, especially if the step count is close to the area.

Example result for input 4 3 10 (scaled 500%):



Brief explanation:

The general approach is:


repeat all the following steps until successful:
initialize 2 matrices: one recording which sides are being used in each cell, and one for the image
if s=0, we're done, else:
pick a random cell and draw a square, then do the following s-1 times:
pick a random direction; if that side is already used, fail and start over
mark the side as used and draw the actual pipe in the image (drawing 3 adjacent lines of length 6, starting right "after" the center pixel of the current cell, then adding a dot to cap the end of the pipe)
update the current position (moving to the next cell)
check if the cell is empty or it's a valid crossing; if not, fail and start over
mark the side in the opposite direction as used in this cell, then continue the loop